<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Easy
  </div>
  <div>
   <h1 class="question_title">
    981. Delete Columns to Make Sorted
   </h1>
   <p>
    We are given an array&nbsp;
    <code>
     A
    </code>
    of
    <code>
     N
    </code>
    lowercase letter strings, all of the same length.
   </p>
   <p>
    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
   </p>
   <p>
    For example, if we have an array
    <code>
     A = ["
    </code>
    <code>
     abcdef
    </code>
    <code>
     ","uvwxyz"]
    </code>
    and deletion indices
    <code>
     {0, 2, 3}
    </code>
    , then the final array after deletions is
    <code>
     ["bef", "vyz"]
    </code>
    ,&nbsp;and the remaining columns of
    <code>
     A
    </code>
    are&nbsp;
    <code>
     ["b"
    </code>
    <code>
     ,"
    </code>
    <code>
     v"]
    </code>
    ,
    <code>
     ["e","y"]
    </code>
    , and
    <code>
     ["f","z"]
    </code>
    .&nbsp; (Formally, the
    <code>
     c
    </code>
    -th column is
    <code>
     [A[0][c], A[1][c], ..., A[A.length-1][c]]
    </code>
    .)
   </p>
   <p>
    Suppose we chose a set of deletion indices
    <code>
     D
    </code>
    such that after deletions, each remaining column in A is in
    <strong>
     non-decreasing
    </strong>
    sorted order.
   </p>
   <p>
    Return the minimum possible value of
    <code>
     D.length
    </code>
    .
   </p>
   <p>
    &nbsp;
   </p>
   <div>
    <p>
     <strong>
      Example 1:
     </strong>
    </p>
    <pre>
<strong>Input: </strong><span id="example-input-1-1">["cba","daf","ghi"]</span>
<strong>Output: </strong><span id="example-output-1">1</span>
<strong>Explanation: </strong>
After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
</pre>
    <div>
     <p>
      <strong>
       Example 2:
      </strong>
     </p>
     <pre>
<strong>Input: </strong><span id="example-input-2-1">["a","b"]</span>
<strong>Output: </strong><span id="example-output-2">0</span>
<strong>Explanation: </strong>D = {}
</pre>
     <div>
      <p>
       <strong>
        Example 3:
       </strong>
      </p>
      <pre>
<strong>Input: </strong><span id="example-input-3-1">["zyx","wvu","tsr"]</span>
<strong>Output: </strong><span id="example-output-3">3</span>
<strong>Explanation: </strong>D = {0, 1, 2}
</pre>
      <p>
       &nbsp;
      </p>
      <p>
       <strong>
        <span>
         Note:
        </span>
       </strong>
      </p>
      <ol>
       <li>
        <code>
         1 &lt;= A.length &lt;= 100
        </code>
       </li>
       <li>
        <code>
         1 &lt;= A[i].length &lt;= 1000
        </code>
       </li>
      </ol>
     </div>
    </div>
   </div>
  </div>
  <div>
   <h1 class="question_title">
    981. 删列造序
   </h1>
   <p>
    给定由&nbsp;
    <code>
     N
    </code>
    &nbsp;个小写字母字符串组成的数组
    <code>
     A
    </code>
    ，其中每个字符串长度相等。
   </p>
   <p>
    选取一个删除索引序列，对于
    <code>
     A
    </code>
    中的每个字符串，删除对应每个索引处的字符。 所余下的字符串行从上往下读形成列。
   </p>
   <p>
    比如，有&nbsp;
    <code>
     A = ["abcdef", "uvwxyz"]
    </code>
    ，删除索引序列&nbsp;
    <code>
     {0, 2, 3}
    </code>
    ，删除后
    <code>
     A
    </code>
    &nbsp;为
    <code>
     ["bef", "vyz"]
    </code>
    ，
    <code>
     A
    </code>
    &nbsp;的列分别为
    <code>
     ["b","v"], ["e","y"], ["f","z"]
    </code>
    。（形式上，第 n&nbsp;列为&nbsp;
    <code>
     [A[0][n], A[1][n], ..., A[A.length-1][n]]
    </code>
    ）。
   </p>
   <p>
    假设，我们选择了一组删除索引&nbsp;
    <code>
     D
    </code>
    ，那么在执行删除操作之后，
    <code>
     A
    </code>
    中所剩余的每一列都必须是
    <strong>
     非降序
    </strong>
    &nbsp;排列的，然后请你返回&nbsp;
    <code>
     D.length
    </code>
    &nbsp;的最小可能值。
   </p>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>["cba", "daf", "ghi"]
<strong>输出：</strong>1
<strong>解释：</strong>
当选择 D = {1}，删除后 A 的列为：["c","d","g"] 和 ["a","f","i"]，均为非降序排列。
若选择 D = {}，那么 A 的列 ["b","a","h"] 就不是非降序排列了。
</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输入：</strong>["a", "b"]
<strong>输出：</strong>0
<strong>解释：</strong>D = {}
</pre>
   <p>
    <strong>
     示例 3：
    </strong>
   </p>
   <pre><strong>输入：</strong>["zyx", "wvu", "tsr"]
<strong>输出：</strong>3
<strong>解释：</strong>D = {0, 1, 2}
</pre>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length &lt;= 100
     </code>
    </li>
    <li>
     <code>
      1 &lt;= A[i].length &lt;= 1000
     </code>
    </li>
   </ol>
  </div>
 </body>
</html>